<%--
  Created by IntelliJ IDEA.
  User: chenbaoyang
  Date: 2021/12/13
  Time: 5:12 下午
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" import="java.util.*,com.cby.web.bean.Person" isELIgnored="false"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
</head>
<script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
        $("#sub").click(function(){
            var form = document.getElementById("myForm");
            var formData = new FormData(form);
            var pid = formData.get("pid");
            var pwd = formData.get("pwd");
            alert(pid+","+pwd);
            var person = {'pid':pid,'name':'Tom','pwd':pwd};
            $.ajax({
                url:"ajax",
                type:"POST",
                dataType: 'json',
                data:person,
                success:function(data){
                    alert(data);
                    if(data == "1"){
                        alert("登录成功");
                        location.href="queryAll";
                    }else {
                        alert("请核对用户名和密码");
                    }
                },
                error:function (xhr) {
                    alert("错误提示： " + xhr.status + " " + xhr.statusText)
                }
            });
        })
    })
</script>
<body>
<form  method="post" id="myForm">
    <table border="1" width="300px">
        <tr>
            <td>帐号</td>
            <td><input type="text" name="pid"/></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" name="pwd"/></td>
        </tr>
        <tr>
            <!-- <td colspan="2"><input type="submit" value="提交"/></td> -->
            <td colspan="2"><input type="button" value="提交" id="sub"/></td>
        </tr>
    </table>
</form>

</body>
</html>
